/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ee.cybertron.energon.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

/**
 *
 * @author stevenziggiz
 */
public class XMLReader {

    /**
     *
     * @param filePath XML file path
     * @param roleName Role name
     * @return Returns the form that corresponds to the role
     * @throws JDOMException Throws an exception when the XML file is disable.
     * @throws IOException Throws an exception when the file path doesn't exist.
     */
    public static List<Element> getRoleForm(InputStream inputStream) throws JDOMException, IOException {
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(inputStream);
        Element root = doc.getRootElement();
        Element body = root.getChild("body", root.getNamespace());
        List<Element> formsList = body.getChildren();
        return formsList;
    }
}
